package servlets;

import beans.StuInfoBean;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import services.StuService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class stuInfoUpdateServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        StuInfoBean stu = JSON.parseObject(request.getParameter("stuInfo"), new TypeReference<>() {});
        StuService stuService = new StuService();
        PrintWriter out = response.getWriter();
        if(stuService.updateStudent(stu) != 0)
            out.write("true");
        else
            out.write("false");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
